<template>
	<view>
		<view class="rf-header-box">
			<view class="rf-header">
				<view style="height: 80rpx;line-height: 80rpx;" class="rf-back" @tap="back">
					<text class="iconfont iconzuo"></text>
				</view>
			</view>
		</view>
		<view style="display: flex;background-color: #eeae00;align-items: center;padding: 30rpx;">
			<view>
				<img src="/static/missing-face.png" width="40"/>
			</view>
			<view style="font-weight: bold;font-size: 35rpx;">分享~</view>
		</view>
		<view class="" style="border-radius: 10rpx;display: flex;margin: 0 20rpx;">
			<view style="flex-grow: 1;">
				<view class="xiao">累计获得奖励（次）</view>
				<view class="da" style="text-align: center;">{{sorce.people}}</view>
			</view>
			<view style="flex-grow: 1;">
				<view class="xiao">累计推广用户</view>
				<view class="da" style="text-align: center;">{{sorce.points}}</view>
			</view>
			<view style="flex-grow: 1;">
				<view class="xiao">获取推广链接</view>
				<view class="da" @click="copyurl()" style="text-align: center;">点击获取</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {getSorce} from "@/api/tgyl.js"
	export default {
		data() {
			return {
				sorce:{}
			}
		},
		onLoad(){
			this.initData();
		},
		methods: {
			async initData(){
				const res = await getSorce("zhangsan");
				this.sorce = res.data.data;
				console.log(this.sorce);
			},
			back() {
				if (this.drawer) {
					this.closeDrawer()
				} else {
					// this.$mRouter.back();
				}
			},
			copyurl(){
				// 微信
				uni.showModal({
						title: '提示',
						content: '确认复制链接吗？',
						success: function(res) {
						if (res.confirm) {
						    // 执行确认后的操作
							uni.setClipboardData({
							data: 'http://1.92.82.82:3000/login?username=zhangsan',
							success: function () {
							console.log('复制成功');
							},
							fail: function (err) {
							console.log('复制失败', err);
							}
							});
						} 
						else {
							// 执行取消后的操作
						}
					}
				})
			}
		}
	}
</script>

<style>
.xiao{
	font-size: 25rpx;
}
.da{
	font-size: 45rpx;
	font-weight: bold;
}
</style>
